<?php


namespace app\common\task;

use app\bbs\model\BbsArticleLabel;
use Lizhichao\Word\VicDict;
use Lizhichao\Word\VicWord;
use yunwuxin\cron\Task;

class SyncWordTask extends Task
{
    public function configure() : void
    {
        $this->expression("*/3 * * * *"); //设置任务的周期，每天执行一次，更多的方法可以查看源代码，都有注释
    }
    protected function execute() : void
    {
        $words = BbsArticleLabel::build()->group('article_label_name')->column('article_label_name');
        $dict = new VicDict();
        foreach ($words as $word){
            $dict->add($word,'n');
            $dict->save();
//            $fc = new VicWord();
//            $arr3 = $fc->getAutoWord('你是一个大狗子 嗷嗷嗷');
//            //        $arr3 = $fc->getAutoWord('你这是一人得道鸡犬升天啊');
//            dd($arr3);
        }
    }
}